﻿using Sunxsh.Es.Common.Util;

namespace Sunxsh.Es.Application;

/// <summary>
/// 设置映射（应用启动时，会自动添加到映射表）
/// </summary>
public class Mapper : IHuaskyMapper
{
    public void Register()
    {
        TypeAdapterConfig<OrderEntity, OrderDto>.NewConfig()
            .Map(dest => dest.Info, src => src.JsonExt.ToObject<OrderInfo>());

        TypeAdapterConfig<OrderDto, OrderEntity>.NewConfig()
            .Map(dest => dest.JsonExt, src => src.Info.ToJson());

        TypeAdapterConfig<ReportEntity, ReportDto>.NewConfig()
            .Map(dest => dest.Info, src => src.JsonExt.ToObject<ReportInfo>());

        TypeAdapterConfig<ReportDto, ReportEntity>.NewConfig()
            .Map(dest => dest.JsonExt, src => src.Info.ToJson());
    }
}
